package org.example.uhy.supports.mechanism;

import org.example.uhy.domain.model.base.DomainEvent;

public class DomainEventPublisher {
    private static final DomainEventPublisher publisher = new DomainEventPublisher();
    private DomainEventEmitStrategy strategy;

    public static DomainEventPublisher instance() {
        return publisher;
    }

    public void publish(DomainEvent event) {
        if (strategy != null) {
            strategy.emit(event);
        }
    }

    public DomainEventEmitStrategy getStrategy() {
        return strategy;
    }

    public void setStrategy(DomainEventEmitStrategy strategy) {
        this.strategy = strategy;
    }
}